package com.tanhua.back.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.back.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Wang.XL
 */
@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {


    /**
     * @param clunme
     * @return
     */
    @Select("SELECT ${clunme} FROM `tb_user_info` GROUP BY ${clunme}")
    List<String> getClunme(String clunme);


    /**
     * @param clunme
     * @param propery
     * @return
     */
    @Select("SELECT COUNT(${clunme}) FROM `tb_user_info` WHERE ${clunme} = #{propery} ")
    int getClunmeCount(String clunme, String propery);

    /**
     * 得到年龄段的数量
     *
     * @param min
     * @param max
     * @param clunme
     * @return
     */
    @Select("SELECT COUNT(#{clunme}) FROM `tb_user_info` WHERE age > #{min} AND age < #{max} ")
    int ageDistribution(int min, int max, String clunme);

    /**
     * 得到所有城市名称
     *
     * @param clunme
     * @return
     */
    @Select("SELECT ${clunme} FROM `tb_user_info`")
    List<String> getArea(String clunme);

    /**
     * 获取一段时间内的综合数据
     *
     * @param beginD
     * @param endD
     * @param cloume
     * @return
     */
    @Select("SELECT SUM(${cloume}) " +
            "FROM " +
            "`tb_analysis_by_day` " +
            "WHERE " +
            "record_date > #{beginD} AND record_date < #{endD}")
    int getAmountByColume(String beginD, String endD, String cloume);

}
